package com.lizhi.menu.service.impl;

import com.lizhi.menu.domain.MenuInfo;
import com.lizhi.menu.mapper.MenuInfoMapper;
import com.lizhi.menu.service.IMenuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 菜谱Service业务层处理
 *
 * @author lizhi
 * @date 2023-05-18
 */
@Service
public class MenuInfoServiceImpl implements IMenuInfoService {
    @Autowired
    private MenuInfoMapper menuInfoMapper;

    /**
     * 查询菜谱
     *
     * @param id 菜谱主键
     * @return 菜谱
     */
    @Override
    public MenuInfo selectMenuInfoById(Long id) {
        return menuInfoMapper.selectById(id);
    }

    /**
     * 查询菜谱列表
     *
     * @param menuInfo 菜谱
     * @return 菜谱
     */
    @Override
    public List<MenuInfo> selectMenuInfoList(MenuInfo menuInfo) {
        return menuInfoMapper.selectMenuInfoList(menuInfo);
    }

    /**
     * 新增菜谱
     *
     * @param menuInfo 菜谱
     * @return 结果
     */
    @Override
    public int insertMenuInfo(MenuInfo menuInfo) {
        menuInfo.setCreateTime(LocalDateTime.now());
        return menuInfoMapper.insertMenuInfo(menuInfo);
    }

    /**
     * 修改菜谱
     *
     * @param menuInfo 菜谱
     * @return 结果
     */
    @Override
    public int updateMenuInfo(MenuInfo menuInfo) {
        return menuInfoMapper.updateMenuInfo(menuInfo);
    }

    /**
     * 批量删除菜谱
     *
     * @param ids 需要删除的菜谱主键
     * @return 结果
     */
    @Override
    public int deleteMenuInfoByIds(Long[] ids) {
        return menuInfoMapper.deleteMenuInfoByIds(ids);
    }

    /**
     * 删除菜谱信息
     *
     * @param id 菜谱主键
     * @return 结果
     */
    @Override
    public int deleteMenuInfoById(Long id) {
        return menuInfoMapper.deleteMenuInfoById(id);
    }
}
